<?php

namespace app\mobile\controller;

use app\BaseController;

use app\Request;
use think\db\Query;
use think\facade\Validate;

use app\mobile\model\Topic;
use app\mobile\model\TopicOption;

/*
 * 题目
 */
class TopicController extends BaseController
{

    /**
     * 题目列表
     * @fun:
     * @author:xfwed
     * @time:2023/06/20 09:21
     */
    public function topicList(){
        $list = Topic::where('is_del',2)
                ->order('sort asc')
                ->field('id,sort,title,target')
                ->select()
                ->each(function($item,$key){
                    $id = $item['id'];
                    //题目选项
                    $item['topicOption'] = TopicOption::where('topic_id',$id)
                            ->where('is_del',2)
                            ->field('id,sort,content,score')
                            ->order('sort asc')
                            ->select();
                    return $item;
                });


        return $this->suc_json('',$list);


    }

}